<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="${pageContext.request.contextPath }/bootstrap/img/favicon.ico">
<link href="${pageContext.request.contextPath }/bootstrap/css/style.min.css?v=4.0.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="${pageContext.request.contextPath}/bootstrap/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrap/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/bootstrap/css/jquery-confirm.css"/>
<link href="${pageContext.request.contextPath }/bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet"/>
<title>医生端管理-审核</title>
</head>
<body>
	<div class="panel panel-default">
	    <div class="panel-body form-group" style="margin-top: 0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">医生职称：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="doctitle" id="doctitle1">
					<option value="">---请选择---</option>
				</select>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">年龄大于：</label>
	        <!-- <div class="col-sm-2">
	            <input type="text" class="form-control" name="docage" id="docage"/>
	        </div> -->
	        <div class="col-sm-2 form-group">
            	<div class="input-daterange input-group" id="docage1">
                	<input type="text" class="input-md form-control" name="docage" id="docage" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" />
            		<span class="input-group-addon">岁</span>
            	</div>
            </div>
            <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">注册手机：</label>
	        <div class="col-sm-2">
	            <input type="text" class="form-control" name="docloginphone" id="docloginphone1"/>
	        </div>
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">所属医院级别：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="dochosplevel" id="dochosplevel1">
					<option value="">---请选择---</option>
				</select>
	        </div>
	    </div>
	    <div class="panel-body form-group" style="margin-top: 0px;">
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">所属科室：</label>
	        <div class="col-sm-2">
	            <select class="form-control" name="dochospfdept" id="dochospfdept1" onchange="loadhospsdept();">
					<option value="0">---请选择一级科室---</option>
				</select>
	        </div>
	        <div class="col-sm-2">
	            <select class="form-control" name="dochospsdept" id="dochospsdept1">
					<option value="0">---请选择二级科室---</option>
				</select>
	        </div>
	        
	        <label class="col-sm-1 control-label" style="text-align: right; margin-top:5px">审核提交时间：</label>
	        <div class="col-sm-3 form-group">
                <div class="input-daterange input-group" id="datepicker">
                    <input type="text" class="input-md form-control" id="startdatetime" name="startdatetime" value="" />
                    <span class="input-group-addon">到</span>
                    <input type="text" class="input-md form-control" id="enddatetime" name="enddatetime" value="" />
                </div>
            </div>
	        <div class="col-sm-1 control-label">
	            <button class="btn btn-primary" id="search_btn">查询</button>
	        </div>
	     </div>
	</div>
    <!-- 动态加载table -->
	<table id="doctortabExamine" class="table table-hover"></table>
	
	<div class="modal inmodal fade" id="agreeModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog modal-lg">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">用户审核</h4>
               	</div>
                <div class="modal-body">
                	<input type="hidden" id="docloginid" />
                	<div class="form-group draggable">
						<label class="control-label">是否同意*</label>
						<select class="form-control" name="isagree" id="isagree" required="" aria-required="true" onchange="isagree()">
							<option value="true">同意</option>
							<option value="false">不同意</option>
						</select>
					</div>
					<div class="form-group draggable">
						<label class="control-label">审核意见*</label>
						<textarea name="idea" onkeyup="words_deal('idea');" id="idea" rows="4"class="form-control" placeholder="填写审核意见，意见会作为推送发送给用户！"></textarea>
					</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                	<button type="button" class="btn btn-primary" onclick="ExamineSubmit()" id="SHBtn">提交</button>
           		</div>
           	</div>
        </div>
	</div>
	<div class="modal inmodal fade" id="DoctorDetailsModal" tabindex="-1" role="dialog"  aria-hidden="true">
    	<div class="modal-dialog" style="width: 1200px">
        	<div class="modal-content">
            	<div class="modal-header">
                	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h3 class="modal-title">用户详情</h3>
               	</div>
                <div class="modal-body">
                    <div class="wrapper wrapper-content">
        				<div class="row animated fadeInRight">
                    		<div class="col-sm-4">
                				<div class="ibox float-e-margins">
                    				<div class="ibox-title">
				                        <h4>个人登陆资料</h4>
				                    </div>
				                    <div>
				                    	<div class="ibox-content profile-content">
			                    			<img alt="image" id="docloginpix" style="max-width:100px" class="img-rounded" src="${pageContext.request.contextPath}/bootstrap/img/a5.jpg">
			                    		</div>
			                    		<div class="ibox-content profile-content">
			                    			<p><i class="fa fa-user"> 登陆手机号码：</i><strong><a id="docloginphone"></a></strong></p>
				                            <hr/>
				                            <p><i class="fa fa-user"> 登陆账号审核状态：</i><strong><a id="doclogintypename"></a></strong></p>
				                            <hr/>
				                            <p><i class="fa fa-map-marker"> 上次登陆时间：</i><strong><a id="doclogintime"></a></strong></p>
				                            <hr/>
			                    		</div>
				                    </div>
				                </div>
				        	</div>
				        	<div class="col-sm-8">
                				<div class="ibox float-e-margins">
                    				<div class="ibox-title">
				                        <h4>个人详细信息</h4>
				                    </div>
				                    <div class="ibox-content">
			                    		<div class="row">
			                    			<div class="col-sm-6">
			                    				<p><i class="fa fa-user"> 真实姓名：</i><strong><a id="docname"></a></strong></p>
												<hr/>
						                    	<p><i class="fa fa-user"> 年龄：</i><strong><a id="docage"></a></strong></p>
						                    	<hr/>
						                    	<p><i class="fa fa-credit-card"> 身份证号码：</i><strong><a id="doccardnum"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在第一科室：</i><strong><a id="docprimarydept"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在经度：</i><strong><a id="dochosplon"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在地址：</i><strong><a id="address1"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在医院：</i><strong><a id="dochosp"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<div class="col-sm-6">
			                    				<p><i class="fa fa-user"> 性别：</i><strong><a id="docmale"></a></strong></p>
												<hr/>
						                    	<p><i class="fa fa-user"> 职称：</i><strong><a id="doctitle"></a></strong></p>
						                    	<hr/>
						                 		<p><i class="fa fa-credit-card"> 是否全天接诊：</i><strong><a id="docallday"></a></strong></p>
						                 		<hr/>
						                    	<p><i class="fa fa-credit-card"> 所在第二科室：</i><strong><a id="docseconddept"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在纬度：</i><strong><a id="dochosplat"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在区和路：</i><strong><a id="address2"></a></strong></p>
						                 		<hr/>
						                 		<p><i class="fa fa-credit-card"> 所在医院等级：</i><strong><a id="hosplevel"></a></strong></p>
						                 		<hr/>
			                    			</div>
			                    			<!-- 显示照片 -->
			                    			<div id="photoPanel">
			                    				
			                    			</div>
			                    		</div>
				                    </div>
				                </div>
				        	</div>
        				</div>
        			</div>
                </div>
				<div class="modal-footer">
                	<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
           		</div>
           	</div>
        </div>
	</div>
    <script src="${pageContext.request.contextPath }/bootstrap/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/jquery-confirm.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrap/js/moment-with-locales.min.js"></script>
	<script src="${pageContext.request.contextPath }/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/fancybox/jquery.fancybox.js"></script>
    <script>
        /* $(document).ready(function(){
        	$(".dataTables-example").dataTable();
			$('#checkall').click(function(){
				$('input[name="check"]').prop("checked",this.checked); 
			});
        });
        function AllExamine(){
        	var check = document.getElementsByName("check");
        	var check_Str=[];
        	for (i in check){
        		if(check[i].checked){
        			check_Str.push(check[i].value);
        		}
        	}
        	if(check_Str!=""){
        		$.confirm({
        		    title: '提示!',
        		    content: '你确定要一键审核？',
        		    type: 'blue',
        		    typeAnimated: true,
        		    buttons: {
        		    	确定: function () {
        		            //$.alert({title:'行号',content:check_Str});
        		            $.ajax({//一键审核，将获取的CheckBox值传输到后台服务端处理
        		            	type:"post",
        		        		url:"${pageContext.request.contextPath}/Main/Doctor/doctorexamineSubmit.action",
        		        		contentType:"application/json;charset=utf-8",
        		        		async: true,
        		        		data:'{"doctorloginids":"'+check_Str+'"}',
        		        		success: function(data){
        		        			if(data==0){
        		        				$.confirm({
        		        					title: '提示!',
        		                		    content: '请求审核的的列为空，请选择一行或多行！！！',
        		                		    type: 'red',
        		                		    typeAnimated: true,
        		                		    buttons: {
        		                		    	确定: function () {},
        		                		    }
        		        				})
        		        			}else if(data==1){
        		        				$.confirm({
        		        					title: '提示!',
        		                		    content: '审核成功！！！',
        		                		    type: 'green',
        		                		    typeAnimated: true,
        		                		    buttons: {
        		                		    	确定: function () {window.location.href="${pageContext.request.contextPath}/Main/Doctor/doctorexamine.action";}
        		                		    }
        		        				})
        		        			}else{
        		        				$.confirm({
        		        					title: '提示!',
        		                		    content: '审核出错，检查ID为   '+data+' 的详情！！！',
        		                		    type: 'red',
        		                		    typeAnimated: true,
        		                		    buttons: {
        		                		    	确定: function () {window.location.href="${pageContext.request.contextPath}/Main/Doctor/doctorexamine.action";}
        		                		    }
        		        				})
        		        			}
        		        		},error:function(msg){
        		        			$.alert({title:'警告',type: 'red',typeAnimated: true,content:"请求延时！！！"});
        		        		}
        		     		})
        		        },
        		       	 取消: function () {
        		            //$.alert('取消!');
        		        },
        		    }
        		});
        	}else{
        		$.alert({
        		    title: '提示!',
        		    content: "请先选择一行或多行",
        		    type: 'red',
        		    typeAnimated: true,
        		    buttons:{确定:function(){}}
        		});
        	}
        } */
      //根据窗口调整表格高度
        $(window).resize(function() {
            $('#doctortabExamine').bootstrapTable('resetView', {
                height: tableHeight()
            })
        })
        //查询按钮事件
        $('#search_btn').click(function(){
            $('#doctortabExamine').bootstrapTable('refresh');
        })
        //tableHeight函数
        function tableHeight(){
            //可以根据自己页面情况进行调整
            return $(window).height();
        }
      	function refreshTab(){
      		$('#doctortabExamine').bootstrapTable('refresh');
      	}
    	//生成用户数据
        $('#doctortabExamine').bootstrapTable({
            method: 'get',
            contentType: "application/x-www-form-urlencoded",//必须要有！！！！
            url:"${pageContext.request.contextPath}/Main/Doctor/doctorListAjax.action",//要请求数据的文件路径
            height:tableHeight(),//高度调整
            striped: true, //是否显示行间隔色
            dataField: "rows",//bootstrap table 可以前端分页也可以后端分页，这里
            //我们使用的是后端分页，后端分页时需返回含有total：总记录数,这个键值好像是固定的  
            //rows： 记录集合 键值可以修改  dataField 自己定义成自己想要的就好
            pageNumber: 1, //初始化加载第一页，默认第一页
            pagination:true,//是否分页
            queryParamsType:'limit',//查询参数组织方式
            queryParams:function(params) {//自定义参数，这里的参数是传给后台的，我这是是分页用的    
                return {//这里的params是table提供的    
                    offset : params.offset,//从数据库第几条记录开始    
                    limit : params.limit,
                    type:2,
	                doctitle:$('#doctitle1').val(),
	                docage:$('#docage1').val(),
	                docloginphone:$('#docloginphone1').val(),
	                dochosplevel:$('#dochosplevel1').val(),
	                dochospfdept:$('#dochospfdept1').val(),
	                dochospsdept:$('#dochospsdept1').val(),
	                startdatetime:$('#startdatetime').val(),
	                enddatetime:$('#enddatetime').val()
                //找多少条    
                };},//请求服务器时所传的参数
            sidePagination:'server',//指定服务器端分页
            pageSize:10,//单页记录数
            pageList:[1,5,10,30,50,100],//分页步进值
            showRefresh:true,//刷新按钮
            showColumns:true,
            clickToSelect: true,//是否启用点击选中行
            toolbarAlign:'right',//工具栏对齐方式
            buttonsAlign:'right',//按钮对齐方式
            toolbar:'#toolbar',//指定工作栏
            columns:[
            	{
	                title:'全选',
	                field:'select',
	                //复选框
	                checkbox:true,
	                width:25,
	                align:'center',
	                valign:'middle'
	            },
	            {
	                title:'医生端登陆ID',
	                field:'docloginid'
	                /* visible:true */
	            },
	            {
	                title:'医生姓名',
	                field:'docname'
	            },
	            {
	                title:'医生性别',
	                field:'docmale'
	            },
	            {
	                title:'医生登陆手机号',
	                field:'docloginphone'
	            },
	            {
	                title:'医生职称',
	                field:'doctitle'
	            },
	            {
	                title:'医生账户状态',
	                field:'doclogintypename'
	            },
	            {
	                title:'操作',
	                field:'doclogintype',
	              	//列数据格式化
	                formatter:operate
	            },
            ],
            locale:'zh-CN',//中文支持,
            responseHandler:function(rows){
                //在ajax获取到数据，渲染表格之前，修改数据源
                return rows;
            }
        })
        //操作序列规则化
		function operate(value,row,index){
    		// data-toggle="modal" data-target="#agreeModal"
			if(value==2){
				return '<button class="btn btn-danger" style="height:30px" data-toggle="modal" data-target="#agreeModal" onclick="Examine('+row.docloginid+')">审核</button>&nbsp&nbsp<button class="btn btn-primary" style="height:30px" onclick="Details('+row.docloginid+')">详情</button>';
		    }else{
			    return '<button class="btn btn-primary" style="height:30px" onclick="Details('+row.docloginid+')">详情</button>';
		    }
		}
    	function Examine(docloginid){
    		//alert(docloginid);
    		$('#docloginid').val(docloginid);
    	}
    	function ExamineSubmit(){
    		var docloginid = $('#docloginid').val();
    		var isagree = $('#isagree').val();
    		var idea=$("#idea").val();
    		//alert("docloginid="+docloginid+"&isagree="+isagree+"&idea="+idea);
    		$.confirm({
    		    title: '提示!',
    		    content: '你确定提交审核？',
    		    type: 'blue',
    		    typeAnimated: true,
    		    buttons: {
    		    	确定: function () {
    		    		$("#SHBtn").html('<i class="fa fa-spinner fa-spin"></i>处理中...');
    		    		$("#SHBtn").prop('disabled',true);
    		    		$.ajax({
    		        		type:'post',
    		        		url:"${pageContext.request.contextPath}/Main/Doctor/doctorexamineSubmit.action",
    		        		data:"docloginid="+docloginid+"&isagree="+isagree+"&idea="+idea,
    		        		async: true,
    		        		success:function(data){
    		        			$("#SHBtn").html('提交');
    	    		    		$("#SHBtn").prop('disabled',false);
    		        			$.alert(data.msg);
    		        			if(data.code==100){
    		        				$('#agreeModal').modal('hide');
    		        				refreshTab();
    		        			}
    		        		},error:function(request){
    		        			$("#SHBtn").html('提交');
    	    		    		$("#SHBtn").prop('disabled',false);
    		        			$.alert("向服务器请求失败！");
    		        		}
    		        	})
    		    	},
    				取消: function () {},
    		    }	
    		});
    		
    	}
    	function Details(docloginid){
    		//alert(docloginid);
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/getDoctorDetails.action",
    			data:"docloginid="+docloginid,
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				$('#DoctorDetailsModal').modal('show');
        				ModalPadding(data.details);
        			}else{
        				$.alert(""+data.msg);
        			}
        		},error:function(request){
        			
        		}
    		})
    	}
	    function datastandard(data){
	    	if(data=='true'){
	    		return "是";
	    	}else if(data=='false'){
	    		return "否";
	    	}else{
	    		return "";
	    	}
	    }
	    function ModalPadding(data){
	    	$("#docloginpix").attr('src',data.docloginpix);//登陆头像
			$("#docloginphone").html(data.docloginphone);//登录手机号码
			$("#doclogintypename").html(data.doclogintypename);//账号登陆状态字
			$("#doclogintime").html(data.doclogintime);//上次登陆时间
			
			$("#docname").html(data.docname);//真实姓名
			$("#docmale").html(data.docmale);//性别
			$("#docage").html(data.docage);//年龄
			$("#doctitle").html(data.doctitle);//职称
			$("#doccardnum").html(data.doccardnum);//身份证号码
			$("#docallday").html(datastandard(data.docallday));//是否全天接诊
			$("#docprimarydept").html(data.docprimarydept);//所在第一科室
			$("#docseconddept").html(data.docseconddept);//所在第二科室
			$("#dochosplon").html(data.dochosplon);//所在经度
			$("#dochosplat").html(data.dochosplat);//所在纬度
			$("#address1").html(data.dochospprovince+","+data.dochospcity);//所在地址
			$("#address2").html(data.dochosparea+","+data.dochospother);//所在地址
			$("#dochosp").html(data.dochosp);//所在医院
			$("#hosplevel").html(data.hosplevel);//所在医院等级
			for(var i=0;i<data.doctitlephoto.length;i++){
				var doctitlephoto=data.doctitlephoto[i];
				var photoname="职称执业医师资格证照片*"+Number(i+1);
				if(doctitlephoto!=""){
					AddPhotoPanel(doctitlephoto,photoname);
				}
			}
			for(var i=0;i<data.docworkcardphoto.length;i++){
				var docworkcardphoto=data.docworkcardphoto[i];
				var photoname="医生工牌照片*"+Number(i+1);
				if(docworkcardphoto!=""){
					AddPhotoPanel(docworkcardphoto,photoname);
				}
			}
			for(var i=0;i<data.doccardphoto.length;i++){
				var doccardphoto=data.doccardphoto[i];
				var photoname="身份证照片*"+Number(i+1);
				if(doccardphoto!=""){
					AddPhotoPanel(doccardphoto,photoname);
				}
			}
			for(var i=0;i<data.docqualphoto.length;i++){
				var docqualphoto=data.docqualphoto[i];
				var photoname="行医资格证照片*"+Number(i+1);
				if(docqualphoto!=""){
					AddPhotoPanel(docqualphoto,photoname);
				}
			}
			for(var i=0;i<data.docotherphoto.length;i++){
				var docotherphoto=data.docotherphoto[i];
				var photoname="其他照片*"+Number(i+1);
				if(docotherphoto!=""){
					AddPhotoPanel(docotherphoto,photoname);
				}
			}
	    }
	    function AddPhotoPanel(data,photoname){
	    	$("#photoPanel").append('<div class="col-sm-6">'+
			    	'<div class="panel panel-default">'+
			    	'<div class="panel-heading">'+
		            	'<h5 class="panel-title">'+
		                	'<a data-toggle="collapse" data-parent="#accordion" href="javscript:;">'+photoname+'</a>'+
		            	'</h5>'+
		            '</div>'+
		     		'<div id="" class="panel-collapse collapse in">'+
	                	'<div class="panel-body">'+
	                       	'<a class="fancybox" target="_blank" href="'+data+'" title="'+photoname+'">'+
					        	'<img alt="image" src="'+data+'" style="width:320px;height:180px;"/>'+
						    '</a> '+
	            		'</div>'+
	            	'</div>'+
	           ' </div>'+
	    	'</div>');
	    }
	    function words_deal(id){
        	var value=$('#'+id).val().length;
	        if(value>150){
	        	var num=$('#'+id).val().substr(0,150);
	        	$('#'+id).val(num);
	        	//alert("超过字数限制，多出的字将被截断！" );
	        }
        }
	    $("#btn_examine").click(function(){
    		var a= $("#doctortabExamine").bootstrapTable('getSelections');
    		 if(a.length<=0){
    			 alert("请选中一行")
    		}else{
    			//var b=JSON.stringify( a );
    			alert(a[0].docloginid);
    		} 
    		
    	});
	</script>
	<script type="text/javascript">
		$(function () {
			$('#startdatetime').datetimepicker({  
				format: 'YYYY-MM-DD',  
				locale: moment.locale('zh-cn')  
			});
			$('#enddatetime').datetimepicker({  
				format: 'YYYY-MM-DD',  
				locale: moment.locale('zh-cn')  
			});
			$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loaddoctitile.action",
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#doctitle1').append("<option value='" + datalist[i].doctitlename + "' >" + datalist[i].doctitlename + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载医生职称失败!!!");
        		}
    		})
    		
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loadhosplevel.action",
    			async: true,
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#dochosplevel1').append("<option value='" + datalist[i].hosplevelname + "' >" + datalist[i].hosplevelname + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载所属医院级别失败!!!");
        		}
    		})
    		
    		$.ajax({
    			type:"post",
    			url:"${pageContext.request.contextPath}/Main/Doctor/loadhospdept.action",
    			async: true,
    			data:"hospdeptfatherid=0",
        		success:function(data){
        			//alert("data.details.docname="+data.details.docname);
        			if(data.code==100){
        				var datalist = data.list;
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#dochospfdept1').append("<option value='" + datalist[i].hospdeptid + "' >" + datalist[i].hospdeptname + "</option>");  
                        }
        			}else{
        				$.alert(data.msg);
        			}
        		},error:function(){
        			$.alert("加载一级科室失败!!!");
        		}
    		})
	    });
		function loadhospsdept(){
	    	var dochospfdept = $("#dochospfdept1").val();
    		if(dochospfdept==0){
                $("#dochospsdept1").empty();
                $('#dochospsdept1').append("<option value='0' selected='selected' >" + '---请选择二级科室---' + "</option>");  
    		}else{
    			$("#dochospsdept1").empty();
    			$.ajax({  //页面首加载一级部门下拉框数据
                    type: "post",  
                    url: "${pageContext.request.contextPath}/Main/Doctor/loadhospdept.action",
            		async: true,
                    data:"hospdeptfatherid="+dochospfdept,
                    success: function (data) {
                    	var datalist = data.list;
                        $('#dochospsdept1').append("<option value='0' selected='selected' >" + '---请选择二级科室---' + "</option>");  
                        for (var i = 0; i < datalist.length; i++) {  
                            $('#dochospsdept1').append("<option value='" + datalist[i].hospdeptid + "' >" + datalist[i].hospdeptname + "</option>");  
                        }  
                    },  
                    error: function () {  
                        $.alert("加载一级部门失败!!!");  
                    }  
                });
    		}
	    }
	</script>
</body>
</html>